﻿using System;
using System.Windows.Forms;
using Un4seen.Bass;

// iconset:
// http://www.iconarchive.com/show/nuoveXT-2-icons-by-saki.3.html

namespace mxplay
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main()
		{
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

			Properties.Settings.Default.Save();
			
			//Зарегестрируем и запустим Bass.Net
			try
			{
				BassNet.Registration(@"mxmgrd@gmail.com", "2X224916152222");
				
			}
			catch (Exception ex)
			{
				throw ex;
			}
			
			/*
			 * ******************************************
			 * Добавим некоторые по умолчанию, которые дизайнер не назначает
			 * ******************************************
			 * 
			 * Добавим столбец title если ещё пусто
			 */
			
			
//			Properties.Settings.Default.PlaylistVisibleColumns.Add("Album");
//			Properties.Settings.Default.PlaylistVisibleColumns.Add("AlbumArtist");
			if(Properties.Settings.Default.PlaylistVisibleColumns==null)
			{
				Properties.Settings.Default.PlaylistVisibleColumns=new System.Collections.Specialized.StringCollection();
			}
			if(Properties.Settings.Default.PlaylistVisibleColumns.Count==0)
			{
				Properties.Settings.Default.PlaylistVisibleColumns.Add("18");
			}
			/*******************************************/
			
			//            Properties.Settings.Default.PlaylistVisibleColumns.Add("12");
			
			FormMain = new mxplay.FormMain();
			FormMain.Text = Application.ProductName;
			FormMain.Shown += new EventHandler(FormMain_Shown);
			Application.Run(FormMain);
		}

		static void FormMain_Shown(object sender, EventArgs e)
		{
			BassCore = new mxplay.BassCore();
		}

		static void Application_ApplicationExit(object sender, EventArgs e)
		{
			mxplay.Properties.Settings.Default.Save();

			if (BassCore != null)
			{
				BassCore.Dispose();
			}
		}

		public static void LogMessage(string message)
		{
			if ((LogWindow == null)||(LogWindow.IsDisposed)||(LogWindow.Disposing))
			{
				LogWindow = new LogWindow();
				LogWindow.Show();
			}

			LogWindow.AddMessage(message);
		}

		internal static FormMain FormMain;
		internal static LogWindow LogWindow;
		internal static BassCore BassCore;
	}
}
